/* InOutCal.java
 *
 * Project/Product: GW
 *
 * Modify Information:
 * =============================================================================
 *   Author	Date       Description
 *   ----------	---------- ---------------------------------------------------
 *   Administrator	2008-12-17	First release
 *
 * Licensed Materials - Property of APEP
 * =============================================================================
 *    (C) COPYRIGHT Shanghai Auto Mart E-Procurement Co., Ltd. 2007 - 2008
 *    All Rights Reserved.
 *
 *    This software is the confidential and proprietary information of
 *    Shanghai Auto Mart E-Procurement Co., Ltd. ("Confidential Information").
 *    You shall not disclose such Confidential Information and shall use it only
 *    in accordance with the terms of the license agreement you entered into 
 *    with Shanghai Auto Mart E-Procurement Co., Ltd.
 *
 * Noties:
 * =============================================================================
 * 
 */

package system.base;

import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

import com.hitrust.gs.lib.GSAutoAuditongDateConfigurator;

import system.LoginContext;
import framework.core.ConstDefine;
import framework.core.DBConnection;
import framework.core.DBEngine;
import framework.core.DBResult;
import framework.core.LogWriter;
import framework.core.ObjectList;

public class InOutCal {
    private String warehouseCode;
    private double yearIn;
    private double yearOut;
    private double monthIn;
    private double monthOut;
    private double dayIn;
    private double dayOut;
    /**
     * @return the warehouseCode
     */
    public String getWarehouseCode() {
        return this.warehouseCode;
    }
    /**
     * @param aWarehouseCode the warehouseCode to set
     */
    public void setWarehouseCode(String aWarehouseCode) {
        this.warehouseCode = aWarehouseCode;
    }
    /**
     * @return the yearIn
     */
    public double getYearIn() {
        return this.yearIn;
    }
    /**
     * @param aYearIn the yearIn to set
     */
    public void setYearIn(double aYearIn) {
        this.yearIn = aYearIn;
    }
    /**
     * @return the yearOut
     */
    public double getYearOut() {
        return this.yearOut;
    }
    /**
     * @param aYearOut the yearOut to set
     */
    public void setYearOut(double aYearOut) {
        this.yearOut = aYearOut;
    }
    /**
     * @return the monthIn
     */
    public double getMonthIn() {
        return this.monthIn;
    }
    /**
     * @param aMonthIn the monthIn to set
     */
    public void setMonthIn(double aMonthIn) {
        this.monthIn = aMonthIn;
    }
    /**
     * @return the monthOut
     */
    public double getMonthOut() {
        return this.monthOut;
    }
    /**
     * @param aMonthOut the monthOut to set
     */
    public void setMonthOut(double aMonthOut) {
        this.monthOut = aMonthOut;
    }
    /**
     * @return the dayIn
     */
    public double getDayIn() {
        return this.dayIn;
    }
    /**
     * @param aDayIn the dayIn to set
     */
    public void setDayIn(double aDayIn) {
        this.dayIn = aDayIn;
    }
    /**
     * @return the dayOut
     */
    public double getDayOut() {
        return this.dayOut;
    }
    /**
     * @param aDayOut the dayOut to set
     */
    public void setDayOut(double aDayOut) {
        this.dayOut = aDayOut;
    }
    
    public static InOutCal fetch(ResultSet rs) throws Exception{
        InOutCal obj = new InOutCal();
        if(rs == null) return obj;
        
        obj.setWarehouseCode(rs.getString("WAREHOUSE_CODE"));
        obj.setYearIn(rs.getDouble("YEAR_IN"));
        obj.setYearOut(rs.getDouble("YEAR_OUT"));
        obj.setMonthIn(rs.getDouble("MONTH_IN"));
        obj.setMonthOut(rs.getDouble("MONTH_OUT"));
        obj.setDayIn(rs.getDouble("DAY_IN"));
        obj.setDayOut(rs.getDouble("DAY_OUT"));
        
        return obj;
    }
    
    public static List findInOutInfo(DBConnection con){
    	List list = new ArrayList();
    	DBResult result = null;
    	String sql = "select * from t_in_out_info";
        try{
        	result = DBEngine.doSelect(con, sql);
            java.sql.ResultSet rs = result.getRs();
            InOutCal obj = null;
            while(rs.next()){
                 obj = InOutCal.fetch(rs);
                 list.add(obj);
            }
        }catch (Exception e) {
			LogWriter.error(e.getMessage());
		}finally{
             if(result!=null)
				try {
					result.clear() ;
				} catch (Exception e) {
					LogWriter.error(e.getMessage());
				}
         }
         
         return list;
    }
    
    //按年月日分别统计进出库数据
    public static List calInOut(DBConnection con, LoginContext loginInfo, String currentDate) throws Exception{
        List list = new ArrayList();
        
        String warehouseCode = "00";
        
        ObjectList warehouses = Warehouse.fetchWarehouses(con, warehouseCode);
        boolean hasSubs = false;
        if(warehouses.size() > 1) hasSubs = true;
        
        //String preWarehouseCode = ConstDefine.getWildCard(warehouseCode);
        String year = currentDate.substring(0, 4);
        String year_month = currentDate.substring(0, 7);
        String year_month_day = currentDate.substring(0, 10);
        
        //统计年度入库金额
        String sql_year_in = "select head.warehouse_code, sum(sub.product_money) year_in, 0 year_out, " +
                             "0 month_in, 0 month_out, 0 day_in, 0 day_out " +
                             "from t_in_sub sub " +
                             "left outer join t_in_head head on sub.in_bill_code = head.in_bill_code " +
                             "where 1=1 ";
        sql_year_in = sql_year_in + "and head.warehouse_code like '" + warehouseCode + "%' ";
        sql_year_in = sql_year_in + "and substr(head.in_time, 1, 4) = '" + year + "' " +
                      "and sub.status = '1' " +
                      "group by head.warehouse_code ";
        
        //统计年度出库金额
        String sql_year_out = "select head.warehouse_code, 0 year_in, sum(sub.product_money) year_out, " +
                              "0 month_in, 0 month_out, 0 day_in, 0 day_out " +
                              "from t_out_sub sub " +
                              "left outer join t_out_head head on sub.out_bill_code = head.out_bill_code " +
                              "where 1=1 ";
        sql_year_out = sql_year_out + "and head.warehouse_code like '" + warehouseCode + "%' ";
        sql_year_out = sql_year_out + "and substr(head.out_time, 1, 4) = '" + year + "' " +
                       "and sub.status = '1' " +
                       "group by head.warehouse_code ";
        
        //统计当月入库金额
        String sql_month_in = "select head.warehouse_code, 0 year_in, 0 year_out, " +
                              "sum(sub.product_money) month_in, 0 month_out, 0 day_in, 0 day_out " +
                              "from t_in_sub sub " +
                              "left outer join t_in_head head on sub.in_bill_code = head.in_bill_code " +
                              "where 1=1 ";
        sql_month_in = sql_month_in + "and head.warehouse_code like '" + warehouseCode + "%' ";
        sql_month_in = sql_month_in + "and substr(head.in_time, 1, 7) = '" + year_month + "' " +
                       "and sub.status = '1' " +
                       "group by head.warehouse_code ";
        
        //统计当月出库金额
        String sql_month_out = "select head.warehouse_code, 0 year_in, 0 year_out, " +
                               "0 month_in, sum(sub.product_money) month_out, 0 day_in, 0 day_out " +
                               "from t_out_sub sub " +
                               "left outer join t_out_head head on sub.out_bill_code = head.out_bill_code " +
                               "where 1=1 ";
        sql_month_out = sql_month_out + "and head.warehouse_code like '" + warehouseCode + "%' ";
        sql_month_out = sql_month_out + "and substr(head.out_time, 1, 7) = '" + year_month + "' " +
                       "and sub.status = '1' " +
                       "group by head.warehouse_code ";
        
        //统计当日入库数据
        String sql_day_in = "select head.warehouse_code, 0 year_in, 0 year_out, " +
                            "0 month_in, 0 month_out, sum(sub.product_money) day_in, 0 day_out " +
                            "from t_in_sub sub " +
                            "left outer join t_in_head head on sub.in_bill_code = head.in_bill_code " +
                            "where 1=1 ";
        sql_day_in = sql_day_in + "and head.warehouse_code like '" + warehouseCode + "%' ";
        sql_day_in = sql_day_in + "and substr(head.in_time, 1, 10) = '" + year_month_day + "' " +
                     "and sub.status = '1' " +
                     "group by head.warehouse_code ";
        
        //统计当日出库数据
        String sql_day_out = "select head.warehouse_code, 0 year_in, 0 year_out, " +
                             "0 month_in, 0 month_out, 0 day_in, sum(sub.product_money) day_out " +
                             "from t_out_sub sub " +
                             "left outer join t_out_head head on sub.out_bill_code = head.out_bill_code " +
                             "where 1=1 ";
        sql_day_out = sql_day_out + "and head.warehouse_code like '" + warehouseCode + "%' ";
        sql_day_out = sql_day_out + "and substr(head.out_time, 1, 10) = '" + year_month_day + "' " +
                      "and sub.status = '1' " +
                      "group by head.warehouse_code ";
        
        
        //---------------------------------------------------------------------------------
        //统计年总部年度入库金额
        String sql_center_year_in = "select '" + warehouseCode + "' warehouse_code, sum(sub.product_money) year_in, 0 year_out, " +
                             "0 month_in, 0 month_out, 0 day_in, 0 day_out " +
                             "from t_in_sub sub " +
                             "left outer join t_in_head head on sub.in_bill_code = head.in_bill_code " +
                             "where 1=1 " +
                             "and substr(head.in_time, 1, 4) = '" + year + "' " +
                             "and sub.status = '1' and head.warehouse_code like '" + warehouseCode + "%'";
        
        //统计总部年度出库金额
        String sql_center_year_out = "select '" + warehouseCode + "' warehouse_code, 0 year_in, sum(sub.product_money) year_out, " +
                              "0 month_in, 0 month_out, 0 day_in, 0 day_out " +
                              "from t_out_sub sub " +
                              "left outer join t_out_head head on sub.out_bill_code = head.out_bill_code " +
                              "where 1=1 " +
                              "and substr(head.out_time, 1, 4) = '" + year + "' " +
                              "and sub.status = '1' and head.warehouse_code like '" + warehouseCode + "%'";
        
        //统计总部当月入库金额
        String sql_center_month_in = "select '" + warehouseCode + "' warehouse_code, 0 year_in, 0 year_out, " +
                              "sum(sub.product_money) month_in, 0 month_out, 0 day_in, 0 day_out " +
                              "from t_in_sub sub " +
                              "left outer join t_in_head head on sub.in_bill_code = head.in_bill_code " +
                              "where 1=1 " +
                              "and substr(head.in_time, 1, 7) = '" + year_month + "' " +
                              "and sub.status = '1' and head.warehouse_code like '" + warehouseCode + "%'";
        
        //统计总部当月出库金额
        String sql_center_month_out = "select '" + warehouseCode + "' warehouse_code, 0 year_in, 0 year_out, " +
                               "0 month_in, sum(sub.product_money) month_out, 0 day_in, 0 day_out " +
                               "from t_out_sub sub " +
                               "left outer join t_out_head head on sub.out_bill_code = head.out_bill_code " +
                               "where 1=1 " +
                               "and substr(head.out_time, 1, 7) = '" + year_month + "' " +
                               "and sub.status = '1' and head.warehouse_code like '" + warehouseCode + "%'";
        
        //统计总部当日入库数据
        String sql_center_day_in = "select '" + warehouseCode + "' warehouse_code, 0 year_in, 0 year_out, " +
                            "0 month_in, 0 month_out, sum(sub.product_money) day_in, 0 day_out " +
                            "from t_in_sub sub " +
                            "left outer join t_in_head head on sub.in_bill_code = head.in_bill_code " +
                            "where 1=1 " +
                            "and substr(head.in_time, 1, 10) = '" + year_month_day + "' " +
                            "and sub.status = '1' and head.warehouse_code like '" + warehouseCode + "%'";
        
        //统计总部当日出库数据
        String sql_center_day_out = "select '" + warehouseCode + "' warehouse_code, 0 year_in, 0 year_out, " +
                             "0 month_in, 0 month_out, 0 day_in, sum(sub.product_money) day_out " +
                             "from t_out_sub sub " +
                             "left outer join t_out_head head on sub.out_bill_code = head.out_bill_code " +
                             "where 1=1 " +
                             "and substr(head.out_time, 1, 10) = '" + year_month_day + "' " +
                             "and sub.status = '1' and head.warehouse_code like '" + warehouseCode + "%'";
        
        //---------------------------------------------------------------------------------
            
        
        //合并查询语句
        String sql = "select warehouse_code, sum(year_in) year_in, sum(year_out) year_out, sum(month_in) month_in, sum(month_out) month_out, sum(day_in) day_in, sum(day_out) day_out from( " +
                     sql_year_in + " union all " + sql_year_out + " union all " +
                     sql_month_in + " union all " + sql_month_out + " union all " +
                     sql_day_in + " union all " + sql_day_out;
        if(hasSubs){
            sql = sql + "union all " + sql_center_year_in +
                  " union all " + sql_center_year_out + " union all " + sql_center_month_in + " union all " + sql_center_month_out +
                  " union all " + sql_center_day_in + " union all " + sql_center_day_out;
        }
        sql = sql + " ) group by warehouse_code order by warehouse_code";
        
        DBResult result = null;
        try
        {
            result = DBEngine.doSelect(con, sql);
            java.sql.ResultSet rs = result.getRs();
            InOutCal obj = null;
            while(rs.next())
            {
                obj = InOutCal.fetch(rs);
                list.add(obj);
            }
        }
        finally
        {
            if(result!=null) result.clear() ;
        }
        
        return list;
    }
    
    //插入inoutinfo表的SQL
    public static String inOutSql(DBConnection con,String currentDate) throws Exception{
        List list = new ArrayList();
        
        String warehouseCode = "00";
        
        ObjectList warehouses = Warehouse.fetchWarehouses(con, warehouseCode);
        boolean hasSubs = false;
        if(warehouses.size() > 1) hasSubs = true;
        
        //String preWarehouseCode = ConstDefine.getWildCard(warehouseCode);
        String year = currentDate.substring(0, 4);
        String year_month = currentDate.substring(0, 7);
        String year_month_day = currentDate.substring(0, 10);
        GSAutoAuditongDateConfigurator.getInstance();
        String[] airWarehouseCode = GSAutoAuditongDateConfigurator.getAirWarehouseCode();
        
        //不统计的仓库
        String sql_air = "";
        if(airWarehouseCode.length>0){
        	for (int i = 0; i < airWarehouseCode.length; i++) {
				sql_air += "and head.warehouse_code <> '"+airWarehouseCode[i]+"' ";
			}
        }
        
        //统计年度入库金额
        String sql_year_in = "select head.warehouse_code, sum(sub.product_money) year_in, 0 year_out, " +
                             "0 month_in, 0 month_out, 0 day_in, 0 day_out " +
                             "from t_in_sub sub " +
                             "left outer join t_in_head head on sub.in_bill_code = head.in_bill_code " +
                             "where 1=1 ";
        sql_year_in = sql_year_in + sql_air;
        sql_year_in = sql_year_in + "and head.warehouse_code like '" + warehouseCode + "%' ";
        sql_year_in = sql_year_in + "and substr(head.in_time, 1, 4) = '" + year + "' " +
                      "and sub.status = '1' " +
                      "group by head.warehouse_code ";
        
        //统计年度出库金额
        String sql_year_out = "select head.warehouse_code, 0 year_in, sum(sub.product_money) year_out, " +
                              "0 month_in, 0 month_out, 0 day_in, 0 day_out " +
                              "from t_out_sub sub " +
                              "left outer join t_out_head head on sub.out_bill_code = head.out_bill_code " +
                              "where 1=1 ";
        sql_year_out = sql_year_out + sql_air;
        sql_year_out = sql_year_out + "and head.warehouse_code like '" + warehouseCode + "%' ";
        sql_year_out = sql_year_out + "and substr(head.out_time, 1, 4) = '" + year + "' " +
                       "and sub.status = '1' " +
                       "group by head.warehouse_code ";
        
        //统计当月入库金额
        String sql_month_in = "select head.warehouse_code, 0 year_in, 0 year_out, " +
                              "sum(sub.product_money) month_in, 0 month_out, 0 day_in, 0 day_out " +
                              "from t_in_sub sub " +
                              "left outer join t_in_head head on sub.in_bill_code = head.in_bill_code " +
                              "where 1=1 ";
        sql_month_in = sql_month_in + sql_air;
        sql_month_in = sql_month_in + "and head.warehouse_code like '" + warehouseCode + "%' ";
        sql_month_in = sql_month_in + "and substr(head.in_time, 1, 7) = '" + year_month + "' " +
                       "and sub.status = '1' " +
                       "and nvl(sub.sub_remark,' ') <> '调价入库退货'"+
                       "and nvl(sub.sub_remark,' ') <> '调价入库'"+
                       "group by head.warehouse_code ";
        
        //统计当月出库金额
        String sql_month_out = "select head.warehouse_code, 0 year_in, 0 year_out, " +
                               "0 month_in, sum(sub.product_money) month_out, 0 day_in, 0 day_out " +
                               "from t_out_sub sub " +
                               "left outer join t_out_head head on sub.out_bill_code = head.out_bill_code " +
                               "where 1=1 ";
        sql_month_out = sql_month_out + sql_air;
        sql_month_out = sql_month_out + "and head.warehouse_code like '" + warehouseCode + "%' ";
        sql_month_out = sql_month_out + "and substr(head.out_time, 1, 7) = '" + year_month + "' " +
                       "and sub.status = '1' " +
                       "and nvl(sub.sub_remark,' ') <> '调价入库退货'"+
                       "and nvl(sub.sub_remark,' ') <> '调价入库'"+
                       "group by head.warehouse_code ";
        
        //统计当日入库数据
        String sql_day_in = "select head.warehouse_code, 0 year_in, 0 year_out, " +
                            "0 month_in, 0 month_out, sum(sub.product_money) day_in, 0 day_out " +
                            "from t_in_sub sub " +
                            "left outer join t_in_head head on sub.in_bill_code = head.in_bill_code " +
                            "where 1=1 ";
        sql_day_in = sql_day_in + sql_air;
        sql_day_in = sql_day_in + "and head.warehouse_code like '" + warehouseCode + "%' ";
        sql_day_in = sql_day_in + "and substr(head.in_time, 1, 10) = '" + year_month_day + "' " +
                     "and sub.status = '1' " +
                     "and nvl(sub.sub_remark,' ') <> '调价入库退货'"+
                     "and nvl(sub.sub_remark,' ') <> '调价入库'"+
                     "group by head.warehouse_code ";
        
        //统计当日出库数据
        String sql_day_out = "select head.warehouse_code, 0 year_in, 0 year_out, " +
                             "0 month_in, 0 month_out, 0 day_in, sum(sub.product_money) day_out " +
                             "from t_out_sub sub " +
                             "left outer join t_out_head head on sub.out_bill_code = head.out_bill_code " +
                             "where 1=1 ";
        sql_day_out = sql_day_out + sql_air;
        sql_day_out = sql_day_out + "and head.warehouse_code like '" + warehouseCode + "%' ";
        sql_day_out = sql_day_out + "and substr(head.out_time, 1, 10) = '" + year_month_day + "' " +
                      "and sub.status = '1' " +
                      "and nvl(sub.sub_remark,' ') <> '调价入库退货'"+
                      "and nvl(sub.sub_remark,' ') <> '调价入库'"+
                      "group by head.warehouse_code ";
        
        
        //---------------------------------------------------------------------------------
        //统计年总部年度入库金额
        String sql_center_year_in = "select '" + warehouseCode + "' warehouse_code, sum(sub.product_money) year_in, 0 year_out, " +
                             "0 month_in, 0 month_out, 0 day_in, 0 day_out " +
                             "from t_in_sub sub " +
                             "left outer join t_in_head head on sub.in_bill_code = head.in_bill_code " +
                             "where 1=1 " +
                             "and substr(head.in_time, 1, 4) = '" + year + "' " +
                             "and sub.status = '1' and head.warehouse_code like '" + warehouseCode + "%'";
        sql_center_year_in += sql_air;
        						
        //统计总部年度出库金额
        String sql_center_year_out = "select '" + warehouseCode + "' warehouse_code, 0 year_in, sum(sub.product_money) year_out, " +
                              "0 month_in, 0 month_out, 0 day_in, 0 day_out " +
                              "from t_out_sub sub " +
                              "left outer join t_out_head head on sub.out_bill_code = head.out_bill_code " +
                              "where 1=1 " +
                              "and substr(head.out_time, 1, 4) = '" + year + "' " +
                              "and sub.status = '1' and head.warehouse_code like '" + warehouseCode + "%'";
        sql_center_year_out += sql_air;
        
        //统计总部当月入库金额
        String sql_center_month_in = "select '" + warehouseCode + "' warehouse_code, 0 year_in, 0 year_out, " +
                              "sum(sub.product_money) month_in, 0 month_out, 0 day_in, 0 day_out " +
                              "from t_in_sub sub " +
                              "left outer join t_in_head head on sub.in_bill_code = head.in_bill_code " +
                              "where 1=1 " +
                              "and substr(head.in_time, 1, 7) = '" + year_month + "' " +
                              "and sub.status = '1' and head.warehouse_code like '" + warehouseCode + "%'";
        sql_center_month_in += sql_air;
        	
        //统计总部当月出库金额
        String sql_center_month_out = "select '" + warehouseCode + "' warehouse_code, 0 year_in, 0 year_out, " +
                               "0 month_in, sum(sub.product_money) month_out, 0 day_in, 0 day_out " +
                               "from t_out_sub sub " +
                               "left outer join t_out_head head on sub.out_bill_code = head.out_bill_code " +
                               "where 1=1 " +
                               "and substr(head.out_time, 1, 7) = '" + year_month + "' " +
                               "and sub.status = '1' and head.warehouse_code like '" + warehouseCode + "%'";
        sql_center_month_out += sql_air;
        
        //统计总部当日入库数据
        String sql_center_day_in = "select '" + warehouseCode + "' warehouse_code, 0 year_in, 0 year_out, " +
                            "0 month_in, 0 month_out, sum(sub.product_money) day_in, 0 day_out " +
                            "from t_in_sub sub " +
                            "left outer join t_in_head head on sub.in_bill_code = head.in_bill_code " +
                            "where 1=1 " +
                            "and substr(head.in_time, 1, 10) = '" + year_month_day + "' " +
                            "and sub.status = '1' and head.warehouse_code like '" + warehouseCode + "%'";
        sql_center_day_in += sql_air;
        
        //统计总部当日出库数据
        String sql_center_day_out = "select '" + warehouseCode + "' warehouse_code, 0 year_in, 0 year_out, " +
                             "0 month_in, 0 month_out, 0 day_in, sum(sub.product_money) day_out " +
                             "from t_out_sub sub " +
                             "left outer join t_out_head head on sub.out_bill_code = head.out_bill_code " +
                             "where 1=1 " +
                             "and substr(head.out_time, 1, 10) = '" + year_month_day + "' " +
                             "and sub.status = '1' and head.warehouse_code like '" + warehouseCode + "%'";
        sql_center_day_out += sql_air;
        //---------------------------------------------------------------------------------
            
        
        //合并查询语句
        String sql = "insert into t_out_in_info select warehouse_code, sum(year_in) year_in, sum(year_out) year_out, sum(month_in) month_in, sum(month_out) month_out, sum(day_in) day_in, sum(day_out) day_out from( " +
                     sql_year_in + " union all " + sql_year_out + " union all " +
                     sql_month_in + " union all " + sql_month_out + " union all " +
                     sql_day_in + " union all " + sql_day_out;
        if(hasSubs){
            sql = sql + "union all " + sql_center_year_in +
                  " union all " + sql_center_year_out + " union all " + sql_center_month_in + " union all " + sql_center_month_out +
                  " union all " + sql_center_day_in + " union all " + sql_center_day_out;
        }
        sql = sql + " ) group by warehouse_code order by warehouse_code";
        LogWriter.info(sql);
        return sql;
    }
    
    //按年月日分别统计进出库数据,查询出入库信息表t_in_out_info
    public static List calInOutBySelectTable(DBConnection con, LoginContext loginInfo, String currentDate) throws Exception{
        List list = new ArrayList();
        
        String sql = "select * from t_out_in_info order by warehouse_code";
        LogWriter.info(sql);
        DBResult result = null;
        try{
            result = DBEngine.doSelect(con, sql);
            java.sql.ResultSet rs = result.getRs();
            InOutCal obj = null;
            while(rs.next()){
                obj = InOutCal.fetch(rs);
                list.add(obj);
            }
        }finally{
            if(result!=null) result.clear() ;
        }
        
        return list;
    }
    
	public static void inOutCompany(DBConnection con) throws Exception {
        List list = new ArrayList();
        
        String sql = "select substr(warehouse_code,0,6) warehouse_code from  t_out_in_info where length(warehouse_code) >=6 group by substr(warehouse_code,0,6)   order by substr(warehouse_code,0,6)";
        LogWriter.info(sql);
        DBResult result = null;
        try{
            result = DBEngine.doSelect(con, sql);
            java.sql.ResultSet rs = result.getRs();
            while(rs.next()){
            	String obj = rs.getString("warehouse_code");
                String insertSql = "select '"+obj+"', sum(year_in),sum(year_out),sum(month_in),sum(month_out),sum(day_in),sum(day_out) from t_out_in_info where warehouse_code like  '"+obj+"%'";
                
            }
        }finally{
            if(result!=null) result.clear() ;
        }
        
   
		
	}

}


